<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link href="/layui/css/layui.css" rel="stylesheet">
<script type="text/javascript" src="/layui/layui.js"></script>
<script type="text/javascript" src="/js/funs.js"></script>
</head>
<body>
<script type="text/html" id="toptoolbar">
<div class="layui-form">
<div class="layui-form-item">
<input name="l_doctor.name">
 <button class="layui-btn layui-btn-sm layui-bg-cyan" lay-event="search">查询</button>
 <button class="layui-btn layui-btn-sm layui-bg-red" lay-event="insert">添加</button>

</div>
</div>
</script>
<script type="text/html" id="rowtoolbar">
<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
<table id="mytab"  lay-filter="mytab"></table>
<script type="text/javascript">

var tab=new LayTable("indexpage");
var cols=[ //表头
    {field: 'name', title: '姓名', width:100}
    ,{field: 'sexname', title: '性别', width:80}
    ,{field: 'department_name', title: '部门名字', width:180}
    ,{field: 'title', title: '职称', width:180}
    ,{fixed: 'right', width:150, align:'center', toolbar: '#rowtoolbar'}
  ];
 tab.RowClick=function(event,row){
	 switch(event){
	    case 'del':
	    	openConfirm("确认删除?",function(){
	    		ajax_get("delete?id="+row.id,function(json){
		    		if(json.status>0){
		    			fresh();
		    		}else{
		    			openAlert(json.msg);
		    		}
		    	});
	    	})
	    	
	    	break;
	    case "edit":
	    	openLayer("edit.html?id="+row.id,"修改",["500px","400px"])
	    	break;
	  }
 }

 tab.ToolClick=function(event){
	 switch(event){
	    case 'search':
	    	tab.selectAll();
	    	break;
	    case "insert":
	    	openLayer("edit.html","新增",["500px","400px"])
	    	break;
	  }
 }
 tab.init(cols,true);
 function fresh(){
		tab.fresh();
}
 
 
</script>

</body>
</html>